package com.bjpowernode.powernotify;

import cn.hutool.core.date.DateUtil;
import com.bjpowernode.powernotify.listener.MessageQueueListener;
import com.bjpowernode.powernotify.queue.PollingTask;
import jakarta.annotation.Resource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
@MapperScan("com.bjpowernode.powernotify.db.mapper")
@SpringBootApplication
public class PowerNotifyApplication implements CommandLineRunner {

	public static DelayQueue<PollingTask> taskDelayQueue = new DelayQueue<>();
	@Resource
	private MessageQueueListener messageQueueListener;

	public static void main(String[] args) {
		SpringApplication.run(PowerNotifyApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		Thread thread = new Thread(() -> {

			System.out.println("====>"+ DateUtil.now()+"|项目启动读取消息开始");
			messageQueueListener.read();
		});
		thread.start();
	}
}
